<?php
namespace app\model;

use think\facade\Db;

/**
 * @desc 管理员分组
 * Class AuthGroup
 * @package app\model
 */
class AuthGroup extends CommonModel
{
    /**
     * 获取管理员所属分组(单个)
     */
    public static function getAdminGroup($adminId)
    {
        return Db::name('auth_group_admin')
            ->alias('aga')
            ->join('auth_group ag', 'aga.group_id = ag.id', 'LEFT')
            ->field('aga.uid,aga.group_id,ag.id,ag.rules,ag.title')
            ->where("aga.uid='{$adminId}'")
            ->find();
    }

    /**
     * 获取管理员所属分组(多个)
     * @param $ids
     * @return array
     */

    public static function getAdminGroupList($ids)
    {
        $ids = implode(',', $ids);
        return Db::name('auth_group_admin')
            ->alias('aga')
            ->join('auth_group ag', 'aga.group_id = ag.id', 'LEFT')
            ->field('aga.uid,aga.group_id,ag.id,ag.rules,ag.title')
            ->where("aga.uid in ({$ids})")
            ->select()
            ->toArray();
    }
}
